home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / SlideShowIE.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-09-04  |  7.7 KB  |  292 lines

  1. /* Program to use Image Engineer to display a whole directory of files, including subdirectories. If a file is an anim, the first frame is displayed. Images can be scaled to a uniform size. If it jams up while trying to load in a binary file which it thinks (wrongly) is a Targa or PCX image, just click on Abort. */
  2.  
  3. /* Written by Don Cox, Oct-Nov 96. Bug fix Sept 99. Copyright, not Public Domain. */
  4. /* $VER:SlideShowIE Sept3 99 */
  5.  
  6.  
  7. /*call open("STDERR","ram:traceSS","W")
  8. trace r*/
  9.  
  10. options results
  11. numeric digits 14
  12.  
  13.  
  14. /* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */
  15.  
  16. address "IMAGEENGINEER"
  17. IE_TO_FRONT
  18.  
  19.  
  20. dir1 = getclip('SlideFiles')
  21. if dir1~="" then 'GET_DIR "Select source directory" "OK" 'dir1 
  22. else 'GET_DIR "Select source directory" "OK" ' 
  23. if rc=10 then exit
  24. directory = result
  25. if upper(directory) = "RAM DISK:" then directory = "Ram:"
  26. directory = expandfilename(directory)
  27. call setclip('SlideFiles',directory)
  28.  
  29. 'GET_NUMBER "Seconds per Image" 1 30 "OK|Cancel" 3'
  30. displaytime = RESULT
  31. if displaytime<1 then displaytime=1
  32.  
  33.  
  34. /* Display files in one directory and its descendents */
  35.  
  36. imagecount = 1
  37. newfile = ""
  38. oldfile = ""
  39.  
  40. address command
  41. 'delete IE:dirlist1'
  42. 'delete IE:dirlist'
  43. 'list >IE:dirlist1 "'directory'" dirs all LFORMAT="%P%S"'
  44. 'sort from IE:dirlist1 to IE:dirlist'
  45. call open("dirinput","IE:dirlist","r")
  46.  
  47. /* First display pics in root directory */
  48. 'delete IE:filelist1'
  49. 'delete IE:filelist'
  50. 'list >IE:filelist1 "'directory'" files LFORMAT="%P%S"'
  51. call open('input',"IE:filelist1","r") /* test in case it's empty */
  52. listtest = readln('input')
  53. call close('input')
  54.  
  55. if listtest~="" then do
  56.     'sort from IE:filelist1 to IE:filelist'
  57.     address "IMAGEENGINEER"
  58.     call dirdisplay
  59.     end
  60.  
  61.  
  62. /* Now do all the subdirectories */
  63.  
  64. if~exists("IE:dirlist") then wayout()
  65.  
  66. listtest = readln("dirinput")
  67. call seek("dirinput",0,'B')
  68. dirtrees = 0
  69. if listtest~="" then do
  70.     'REQUEST "Show images in Subdirectories?" "Yes|No"' 
  71.     dirtrees = rc
  72.     end
  73.  
  74. do d = 1 to 700
  75.     dirname = readln("dirinput")
  76.     if dirname = "" then break
  77.     address command
  78.     'delete IE:filelist1'
  79.     'delete IE:filelist'
  80.     'list >IE:filelist1 "'dirname'" files LFORMAT="%P%S"'
  81.     call open('input2',"IE:filelist1","r") /* test in case it's empty */
  82.     listtest = readln('input2')
  83.     call close('input2')
  84.  
  85.     if listtest~="" then do
  86.         'sort from IE:filelist1 to IE:filelist'
  87.         address "IMAGEENGINEER"
  88.         call dirdisplay
  89.         end
  90.     end
  91.  
  92. wayout:
  93. address "IMAGEENGINEER"
  94. IE_TO_FRONT
  95. 'REQUEST "   Finished   "'
  96. exit
  97. end
  98.  
  99. /* ++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */
  100.  
  101.  
  102. getpath:
  103. parse arg allname
  104. pos1 = lastpos("/",allname)
  105. if pos1 = 0 then pos1 = lastpos(":",allname)
  106. filepath = left(allname,pos1)
  107. return filepath
  108.  
  109. getname:
  110. parse arg allname
  111. pos1 = lastpos("/",allname)
  112. if pos1 = 0 then pos1 = lastpos(":",allname)
  113. justname = substr(allname,pos1+1)
  114. return justname 
  115.  
  116. expandfilename: procedure
  117.   parse arg jfile;
  118.   if index(jfile,':') = 0 then do
  119.     curdir = pragma(D);
  120.     if right(curdir,1) ~= ':' then do
  121.       if right(curdir,1) ~= '/' then do
  122.         if curdir ~= '' then do
  123.           curdir = curdir || '/';
  124.           end;
  125.         end;
  126.       end;
  127.     jfile = curdir||jfile;
  128.     end;
  129.   return jfile
  130.  
  131. rounded: procedure
  132. parse arg number
  133. originalNumber = number
  134. number = trunc(number)
  135. if (originalNumber-number)>0.5 then number=number+1
  136. return number
  137.  
  138.  
  139. /* ++++++++++++++++++++++++++++++  ++++++++++++++++++++++++++++++++++*/
  140.  
  141. /* Display all the pics in one directory */
  142. dirdisplay:
  143. address "IMAGEENGINEER"
  144.  
  145.  
  146. call open('input3',"IE:filelist","r")
  147. do i = 1 to 7000   /* safety limit of 7000 files  */
  148.     filename = readln('input3')
  149.     if filename = "" then break
  150.     
  151.     slashpos = lastpos("/",filename)
  152.     dotpos = lastpos(".",filename)
  153.     if dotpos<slashpos then dotpos = 0 /* not dots in directory names */
  154.     if dotpos~=0 then extension = upper(substr(filename,dotpos))
  155.     else extension = ""
  156.     extensionlist = ".INFO .PSFONT .FONT .PDFONT .PFB .AFM .METRIC .LIB .DEM .DOC .TXT .WP .README .ME .ZIP .ARC .ME .DAT .EXE .PIF .INI .TF .DB .C .H .GF .PPRX .PDRX .REXX .ADPRO .CFG .PREFS .HTM .HTML"
  157.     if pos(upper(extension),extensionlist)~=0 then iterate i
  158.     if word(filename,2) = "files" then iterate i /* This line not a file name */
  159.     if filename="Ram:traceSS" then iterate i
  160.     if word(filename,1) = "TOTAL:" then break  /* or this one */
  161.  
  162.     if upper(extension) = ".LHA" then call UnArc()
  163.     else success = showpic()
  164.  
  165.  
  166.     end    /* end of directory */
  167.  
  168. call close('input3')
  169.  
  170.  
  171. return
  172.  
  173. /* +++++++++++++++++++++++++++++++  +++++++++++++++++++++++++++++++++ */
  174.  
  175. showpic:
  176.  
  177. if ~open("picinput",filename,"R") then return 1
  178. chunks = readch("picinput",1000)
  179. call close("picinput")
  180. if left(chunks, 4) = ".key" then return 1 /* skip Shell scripts */
  181.  
  182. address 'IMAGEENGINEER'
  183.  
  184. 'OPEN "'filename'"' /* Quotes allow file names with spaces */
  185. if rc ~=0 then return 1 /* if load fails, try the next one */
  186. newfile = result
  187. if oldfile~="" then 'CLOSE "'oldfile'"'
  188. oldfile = newfile
  189.  
  190. address command
  191. "wait "displaytime
  192. address 'IMAGEENGINEER'
  193.  
  194. return 0
  195.  
  196. /* ++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
  197.  
  198. /* Unarchive LHA files to HD and display temporary dir */
  199. UnArc:
  200. if ~exists("c:lha") then return 1
  201. address command
  202. if exists("IE:ssarc") then 'delete IE:ssarc all' /* gets rid of any crash-producing files left from previous run */
  203. 'makedir IE:ssarc'
  204.  
  205. 'lha e -f "'filename'" IE:ssarc/'
  206.  
  207.  
  208. /* Display files in archive directory and its descendents. LHA files within LHA files are NOT expanded. */
  209.  
  210. arcimagecount = 1
  211.  
  212. address command
  213. 'delete IE:arcdirlist1'
  214. 'delete IE:arcdirlist'
  215. 'list >IE:arcdirlist1 IE:ssarc dirs all LFORMAT="%P%S"'
  216. 'sort from IE:arcdirlist1 to IE:arcdirlist'
  217. call open("arcdirinput","IE:arcdirlist","r")
  218.  
  219. /* First display pics in root directory */
  220. 'delete IE:arcfilelist1'
  221. 'delete IE:arcfilelist'
  222. 'list >IE:arcfilelist1 IE:ssarc files LFORMAT="%P%S"'
  223. call open('arcinput',"IE:arcfilelist1","r") /* test in case it's empty */
  224. listtest = readln('arcinput')
  225. call close('arcinput')
  226.  
  227. if listtest~="" then do
  228.     'sort from IE:arcfilelist1 to IE:arcfilelist'
  229.     address "IMAGEENGINEER"
  230.     call arcdirdisplay
  231.     end
  232.  
  233.  
  234. /* Now do all the archive subdirectories */
  235.  
  236. if~exists("IE:arcdirlist") then return
  237.  
  238. listtest = readln("arcdirinput")
  239. call seek("arcdirinput",0,'B')
  240.  
  241. do d = 1 to 700
  242.     arcdirname = readln("arcdirinput")
  243.     if arcdirname = "" then break
  244.     address command
  245.     'delete IE:arcfilelist1'
  246.     'delete IE:arcfilelist'
  247.     'list >IE:arcfilelist1 "'arcdirname'" files LFORMAT="%P%S"'
  248.     call open('arcinput2',"IE:arcfilelist1","r") /* test in case it's empty */
  249.     listtest = readln('arcinput2')
  250.     call close('arcinput2')
  251.  
  252.     if listtest~="" then do
  253.         'sort from IE:arcfilelist1 to IE:arcfilelist'
  254.         address "IMAGEENGINEER"
  255.         call arcdirdisplay
  256.         end
  257.     end
  258. call close("arcdirinput")
  259. 'delete IE:ssarc all'
  260. return
  261.  
  262. /* +++++++++++++++++++++++++++++  ++++++++++++++++++++++++++++++++++  */
  263.  
  264. arcdirdisplay:
  265.  
  266. call open('inputarc',"IE:arcfilelist","r")
  267. do a = 1 to 7000   /* safety limit of 7000 files  */
  268.     address command
  269.     filename = readln('inputarc')
  270.     if filename = "" then break
  271.     
  272.     slashpos = lastpos("/",filename)
  273.     dotpos = lastpos(".",filename)
  274.     if dotpos<slashpos then dotpos = 0 /* not dots in directory names */
  275.     if dotpos~=0 then extension = upper(substr(filename,dotpos))
  276.     else extension = ""
  277.     /* Note: this time filter out LHA files */
  278.     extensionlist = extensionlist||" .LHA"
  279.     if pos(upper(extension),extensionlist)~=0 then iterate a
  280.     if word(filename,2) = "files" then iterate /* This line not a file name */
  281.     if filename="Ram:traceSS" then iterate
  282.     if word(filename,1) = "TOTAL:" then break  /* or this one */
  283.  
  284.     success = showpic()
  285.     end    /* end of directory */
  286.  
  287. call close('inputarc')
  288.  
  289.  
  290. return 0
  291.  
  292.